<template>
  <div class="column-detail-page w-75 mx-auto">
    <div class="column-info row mb-4 border-bottom pb-4 align-items-center" v-if="column">
      <div class="col-3 text-center">
        <img :src="column.avatar && column.avatar.fitUrl" :alt="column.title" class="rounded-circle border w-100">
      </div>
      <div class="col-9">
        <h4>{{column.title}}</h4>
        <p class="text-muted">{{column.description}}</p>
      </div>
    </div>
    <post-list :list="list"></post-list>
    <!-- <button
      class="btn btn-outline-primary mt-2 mb-5 mx-auto btn-block w-25 d-block"
      @click="loadMorePage" v-if="!isLastPage"
    >
      加载更多
    </button> -->
  </div>
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue';
import {useRoute} from 'vue-router';
import {useStore} from 'vuex'
import PostList from '@/components/PostList.vue';
import { testData,testPosts } from '@/testData';
export default defineComponent({
  components:{
    PostList
  },
  setup(){
    const route = useRoute()
    const store = useStore()
    const currentId = +route.params.id
    // const column = testData.find(c=>c.id===currentId)
    // const list = testPosts.filter(post=>post.columnId===currentId)
    const column = computed(()=>store.getters.getColumnById(currentId))
    const list = computed(()=>store.getters.getPostsById(currentId))
    return {
      column,
      list
    }
  }
})
</script>

<style>

</style>